(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

f(X) → if(X, c, n__f(true))
if(true, X, Y) → X
if(false, X, Y) → activate(Y)
f(X) → n__f(X)
activate(n__f(X)) → f(X)
activate(X) → X

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

f(X) → if(X, c, n__f(true)) [1]
if(true, X, Y) → X [1]
if(false, X, Y) → activate(Y) [1]
f(X) → n__f(X) [1]
activate(n__f(X)) → f(X) [1]
activate(X) → X [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(X) → if(X, c, n__f(true)) [1]
if(true, X, Y) → X [1]
if(false, X, Y) → activate(Y) [1]
f(X) → n__f(X) [1]
activate(n__f(X)) → f(X) [1]
activate(X) → X [1]

The TRS has the following type information:
f :: true:false → c:n__f
if :: true:false → c:n__f → c:n__f → c:n__f
c :: c:n__f
n__f :: true:false → c:n__f
true :: true:false
false :: true:false
activate :: c:n__f → c:n__f

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:
none

And the following fresh constants: none

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(X) → if(X, c, n__f(true)) [1]
if(true, X, Y) → X [1]
if(false, X, Y) → activate(Y) [1]
f(X) → n__f(X) [1]
activate(n__f(X)) → f(X) [1]
activate(X) → X [1]

The TRS has the following type information:
f :: true:false → c:n__f
if :: true:false → c:n__f → c:n__f → c:n__f
c :: c:n__f
n__f :: true:false → c:n__f
true :: true:false
false :: true:false
activate :: c:n__f → c:n__f

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

c => 0
true => 1
false => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

activate(z) -{ 1 }→ X :|: X >= 0, z = X
activate(z) -{ 1 }→ f(X) :|: z = 1 + X, X >= 0
f(z) -{ 1 }→ if(X, 0, 1 + 1) :|: X >= 0, z = X
f(z) -{ 1 }→ 1 + X :|: X >= 0, z = X
if(z, z', z'') -{ 1 }→ X :|: z' = X, Y >= 0, z = 1, z'' = Y, X >= 0
if(z, z', z'') -{ 1 }→ activate(Y) :|: z' = X, Y >= 0, z'' = Y, X >= 0, z = 0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1, V2),0,[f(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[if(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[activate(V, Out)],[V >= 0]).
eq(f(V, Out),1,[if(X1, 0, 1 + 1, Ret)],[Out = Ret,X1 >= 0,V = X1]).
eq(if(V, V1, V2, Out),1,[],[Out = X2,V1 = X2,Y1 >= 0,V = 1,V2 = Y1,X2 >= 0]).
eq(if(V, V1, V2, Out),1,[activate(Y2, Ret1)],[Out = Ret1,V1 = X3,Y2 >= 0,V2 = Y2,X3 >= 0,V = 0]).
eq(f(V, Out),1,[],[Out = 1 + X4,X4 >= 0,V = X4]).
eq(activate(V, Out),1,[f(X5, Ret2)],[Out = Ret2,V = 1 + X5,X5 >= 0]).
eq(activate(V, Out),1,[],[Out = X6,X6 >= 0,V = X6]).
input_output_vars(f(V,Out),[V],[Out]).
input_output_vars(if(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(activate(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [activate/2,f/2,if/4]
1. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into f/2
1. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations f/2
* CE 10 is refined into CE [11]
* CE 9 is refined into CE [12]
* CE 7 is refined into CE [13]
* CE 8 is refined into CE [14]


### Cost equations --> "Loop" of f/2
* CEs [14] --> Loop 6
* CEs [11] --> Loop 7
* CEs [12] --> Loop 8
* CEs [13] --> Loop 9

### Ranking functions of CR f(V,Out)

#### Partial ranking functions of CR f(V,Out)


### Specialization of cost equations start/3
* CE 2 is refined into CE [15]
* CE 3 is refined into CE [16]
* CE 4 is refined into CE [17,18,19,20]
* CE 5 is refined into CE [21,22,23,24]
* CE 6 is refined into CE [25,26,27,28]


### Cost equations --> "Loop" of start/3
* CEs [23] --> Loop 10
* CEs [21,22,27] --> Loop 11
* CEs [15,16,17,18,19,20,24,25,26,28] --> Loop 12

### Ranking functions of CR start(V,V1,V2)

#### Partial ranking functions of CR start(V,V1,V2)


Computing Bounds
=====================================

#### Cost of chains of f(V,Out):
* Chain [9]: 3
with precondition: [V=0,Out=2]

* Chain [8]: 2
with precondition: [V=1,Out=0]

* Chain [7]: 1
with precondition: [V+1=Out,V>=0]

* Chain [6,8]: 5
with precondition: [V=0,Out=0]

* Chain [6,7]: 4
with precondition: [V=0,Out=2]


#### Cost of chains of start(V,V1,V2):
* Chain [12]: 7
with precondition: [V>=0]

* Chain [11]: 6
with precondition: [V=1]

* Chain [10]: 3
with precondition: [V=2]


Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [12] with precondition: [V>=0]
- Upper bound: 7
- Complexity: constant
* Chain [11] with precondition: [V=1]
- Upper bound: 6
- Complexity: constant
* Chain [10] with precondition: [V=2]
- Upper bound: 3
- Complexity: constant

### Maximum cost of start(V,V1,V2): 7
Asymptotic class: constant
* Total analysis performed in 66 ms.

(10) BOUNDS(1, 1)